package com.builder.settings;

import com.builder.settings.interfaces.HelperStorage;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sad
 */
public class DefaultHelperStorage extends HelperStorage {

    private static class HelpEntity {

        private String key;
        private String help;

        public HelpEntity(String key, String help) {
            this.key = key;
            this.help = help;
        }

        public String getKey() {
            return key;
        }

        public String getHelp() {
            return help;
        }
    }

    private final Map<String, HelpEntity> helpMap = new HashMap<String, HelpEntity>();

    private DefaultHelperStorage addEntity(HelpEntity e){
        helpMap.put(e.key, e);
        return this;
    }
    public DefaultHelperStorage addEntity(String key, String help){
        addEntity(new HelpEntity(key, help));
        return this;
    }
    
    @Override
    public boolean contains(String key) {
        return helpMap.containsKey(key);
    }

    @Override
    public String getHelp(String key) {
        HelpEntity entity = helpMap.get(key);
        if (entity == null) {
            return null;
        }
        return entity.help;
    }

    @Override
    public List<String> getAllKeysForAutocomplete() {
        return new ArrayList<>(helpMap.keySet());
    }

}
